const mysql = require('mysql');

const connectObj = mysql.createConnection({
    host: 'localhost',
    port: '3306',
    user: 'root',
    password: 'root',
    database: 'u_class'
})

// 封装查询
function query(sql='') {
    return new Promise(resolve => {
        connectObj.query(sql, (err, result) => {
            if(err) {
                console.log(err);
                return;
            }
            resolve(result);
        })
    })
}

module.exports = query;